import math
def vectorProduct(a,b):
    len=a.__len__()
    sum=0
    for i in range(len):
        sum+=a[i]*b[i]
    return sum

def getDistance(a,b):
    len=a.__len__()
    sum=0
    for i in range(len):
        sum+=(a[i]-b[i])**2
    return sum**0.5
def GaussKernel(x,l,sigma2):
    '''
    :param x:
    :param l:
    :param sigma2: sigma2越小表示对相似程度的判断越严格,使得SVM误差小方差大过拟合
    :return:
    '''
    sum=0
    n=x.__len__()
    for i in range(n):
        sum+=(x[i]-l[i])**2
    return math.exp(-sum/(2*sigma2))
if __name__=='__main__':
    print(GaussKernel([1,2],[1,1],100))